package com.code.app.activity;

import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import com.code.app.R;
import com.code.app.base.BaseActivity;
import com.code.app.floatview.FloatCircleView;
import com.code.app.floatview.FloatCircleViewService;
import com.code.app.view.QQStepView;
import com.code.app.view.TextView;

public class CustomViewActivity extends BaseActivity {

    private QQStepView QQStepView;

    @Override
    public int getLayoutId() {
        return R.layout.activity_customview;
    }

    @Override
    public void initFunction(Bundle savedInstanceState) {
        QQStepView = findViewById(R.id.step_view);

    }

    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.loading:
                Intent intentL = new Intent(this, LoadingActivity.class);
                startActivity(intentL);
                break;
                case R.id.touch:
                Intent intentT = new Intent(this, TouchActivity.class);
                startActivity(intentT);
                break;
                case R.id.drag:
                Intent intentD = new Intent(this, DragActivity.class);
                startActivity(intentD);
                break;
            case R.id.step_start:
                startSetView();
                break;
            case R.id.open_float:
                Intent intent = new Intent(this, FloatCircleViewService.class);
                startService(intent);
                break;
        }
    }

    public void startSetView() {
        QQStepView.setStepMax(1000);
        final ValueAnimator valueAnimator = ObjectAnimator.ofFloat(0, 666);
        valueAnimator.setDuration(3000);
        valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator valueAnimator) {
                float value = (float) valueAnimator.getAnimatedValue();
                QQStepView.setCurrentStep((int) value);
            }
        });
        valueAnimator.start();
    }
}
